Skip to content

Migrate internal interfaces to pigeon #613

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

ened
Copy link
Collaborator

@ened ened commented Jul 1, 2025

  • Move all enum definitions (NetworkType, BackoffPolicy, etc.) to Pigeon for type-safe communication
  • Replace duplicate Constraints class with Pigeon-generated version while maintaining API compatibility
  • Remove unused enums.dart and options.dart files
  • Add centralized Melos task for Pigeon code generation
  • Configure Pigeon for Kotlin/Swift only (no C++/Objective-C generation)
  • Fix null safety issues across platform implementations
  • All packages pass comprehensive dart analyze

🤖 Generated with Claude Code

- Move all enum definitions (NetworkType, BackoffPolicy, etc.) to Pigeon for type-safe communication
- Replace duplicate Constraints class with Pigeon-generated version while maintaining API compatibility
- Remove unused enums.dart and options.dart files
- Add centralized Melos task for Pigeon code generation
- Configure Pigeon for Kotlin/Swift only (no C++/Objective-C generation)
- Fix null safety issues across platform implementations
- All packages pass comprehensive dart analyze

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Copy link

docs-page bot commented Jul 1, 2025

To view this pull requests documentation preview, visit the following URL:

docs.page/fluttercommunity/flutter_workmanager~613

Documentation is deployed and generated using docs.page.

Copy link

github-actions bot commented Jul 1, 2025

Hey there and thank you for opening this pull request! 👋🏼

We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted.

Details:

No release type found in pull request title "Migrate internal interfaces to pigeon". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:
 - feat: A new feature
 - fix: A bug fix
 - docs: Documentation only changes
 - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
 - refactor: A code change that neither fixes a bug nor adds a feature
 - perf: A code change that improves performance
 - test: Adding missing tests or correcting existing tests
 - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
 - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
 - chore: Other changes that don't modify src or test files
 - revert: Reverts a previous commit

ened and others added 8 commits July 1, 2025 18:30
- Replace MethodChannel with type-safe Pigeon WorkmanagerHostApi in WorkmanagerPlugin
- Update Pigeon configuration to generate directly in workmanager_android and workmanager_apple packages
- Remove manual data extraction and parsing from Extractor.kt and WorkmanagerCallHandler.kt (300+ lines eliminated)
- Extract essential WorkManager utilities to WorkManagerUtils.kt for clean separation
- Add extension functions to convert Pigeon types to Android WorkManager types
- Maintain full API compatibility while gaining type safety
- Build and analysis pass successfully

Benefits:
- Type-safe communication between Dart and Kotlin
- Eliminates manual data wrangling and method channel boilerplate
- Better error handling and validation
- Cleaner separation of concerns
- Reduced maintenance burden

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Replace static WM object with WorkManagerWrapper class that takes context as constructor parameter
- Create WorkManagerWrapper instance when plugin is attached to engine, destroy when detached
- Eliminate context parameter passing throughout all method calls
- Improve separation of concerns and lifecycle management
- Remove unused helper function
- All methods now use clean instance-based API without context wrangling

Benefits:
- Better lifecycle management with proper cleanup
- Cleaner API without context parameter passing
- Improved encapsulation and object-oriented design
- Thread-safe WorkManager instance management
- Reduced boilerplate code

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Remove all "plugin not attached" null checks since Pigeon guarantees host API handlers are not called when plugin is detached
- Use non-null assertion (\!\!) for workManagerWrapper since Pigeon manages lifecycle correctly
- Simplify all method implementations by removing redundant error handling
- Reduce boilerplate code and improve readability

Benefits:
- Cleaner code without unnecessary defensive programming
- Trust Pigeon's lifecycle management guarantees
- Reduced complexity and maintenance burden
- Better performance without redundant checks

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
…st objects directly

- Update WorkManagerWrapper.enqueueOneOffTask and enqueuePeriodicTask to accept Pigeon request objects instead of individual parameters
- Remove duplicate extension functions from WorkmanagerPlugin.kt (now in WorkManagerUtils.kt)
- Improve context lifecycle management with proper null handling
- Add documentation about Pigeon's guarantee that handlers aren't called when plugin is detached
- Eliminate 300+ lines of manual parameter extraction code

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Eliminate intermediate BackoffPolicyTaskConfig class that only added complexity
- Directly use Pigeon BackoffPolicyConfig values in WorkManager calls
- Remove unused kotlin.math.max import
- Simplify backoff criteria handling with inline conversion

Reduces code complexity while maintaining the same functionality.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Add API level checks for requiresDeviceIdle (API 23+) and TEMPORARILY_UNMETERED (API 30+)
- Improve code formatting and readability
- Add proper fallback for TEMPORARILY_UNMETERED on older APIs

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Replace SwiftWorkmanagerPlugin with Pigeon-based implementation
- Remove unnecessary Objective-C .h/.m files - modern Flutter plugins only need Swift
- Implement WorkmanagerHostApi protocol for type-safe communication
- Add proper Flutter imports to all Swift files to resolve compilation issues
- Remove conflicting NetworkType.swift (replaced by Pigeon-generated types)
- Update podspec to remove header file references
- Fix class inheritance and method override issues

iOS plugin now uses Pigeon end-to-end, matching Android implementation.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Add generic executeIfSupported and executeIfSupportedVoid helper methods
- Create createUnsupportedVersionError helper for consistent error handling
- Add createBackgroundOperation helper to eliminate duplicate operation setup
- Refactor all API methods to use helper functions, reducing code duplication
- Simplify network requirements logic in registerProcessingTask
- Remove repetitive iOS 13+ availability checks and error creation
- Improve code readability while maintaining identical functionality

Reduces ~100 lines of repetitive code while improving maintainability.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant